<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>添加栏目 </title>

    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">

    <!-- Styles -->
    <link href="__ADMIN_OTHER__/fontAwesome/css/fontawesome-all.min.css" rel="stylesheet">
    <link href="__ADMIN_CSS__/lib/themify-icons.css" rel="stylesheet">
    <link href="__ADMIN_CSS__/lib/mmc-chat.css" rel="stylesheet" />
    <link href="__ADMIN_CSS__/lib/sidebar.css" rel="stylesheet">
    <link href="__ADMIN_CSS__/lib/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN_CSS__/lib/nixon.css" rel="stylesheet">
    <link href="__ADMIN_CSS__/style.css" rel="stylesheet">
</head>

<body>

{include file="public/menu"}
<!-- /# sidebar -->
{include file="public/header"}

<div class="content-wrap">
    <div class="main">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-8 p-0">
                    <div class="page-header">
                        <div class="page-title">
                            <h1></h1>
                        </div>
                    </div>
                </div>
                <div class="col-lg-4 p-0">
                    <div class="page-header">
                        <div class="page-title">
                            <ol class="breadcrumb text-right">
                                <li><a>栏目列表</a></li>
                                <li class="active">栏目添加</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
            <div class="main-content">
                <form action="" method="post" id="topform">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card alert">
                                <div class="card-header">
                                    <h4 >一级栏目添加</h4>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                            <div class="form-group">
                                                <label>名称</label>
                                                <input type="text" name="topName" id="topName" class="form-control" value="" placeholder="一级栏目名称">
                                            </div>
                                            <div class="form-group">
                                                <label>图标</label>
                                                <input type="text" name="icon" id="icon" class="form-control" value="" placeholder="图标代码 (下方为图标列表)">
                                            </div>
                                            <div class="form-group">
                                                <label>链接</label>
                                                <input type="text" name="clas" id="clas" class="form-control" value="" placeholder="url (直接写控制器名称 【例如：AdminUser】)">
                                            </div>
                                            <button type="button" onclick="subtop();" class="btn btn-success m-b-10 m-l-5">添加一级栏目</button>
                                    </div>
                                </div>
                            </div>
                        </div><!-- /# column -->
                    </div><!-- /# row -->
                </form>

                {include file="public/icon"}


                <form action="/admin/MenuAdd" method="post">
                <div class="row">
                    <div class="col-lg-6">
                        <div class="card alert">
                            <div class="card-header">
                                <h4>二级栏目添加</h4>
                            </div>
                            <div class="card-body">
                                <div class="basic-form">
                                        <div class="form-group">
                                            <label>名称</label>
                                            <input type="text" name="secondName" id="secondName" class="form-control" placeholder="二级名称">
                                        </div>
                                        <div class="form-group">
                                            <label>链接</label>
                                            <input type="text" name="sclas" id="sclas" class="form-control" placeholder="直接写方法名【例如：userList】">
                                        </div>
                                        <div class="form-group">
                                            <label>归属一级栏目</label>
                                            <select class="form-control" name="pid" id="pid">
                                                <option selected="selected" value="">未选择</option>
                                                {volist name='rs' id='vo'}
                                                <option value="{$vo.id}">{$vo.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                        <button type="button" onclick="subsecond();" class="btn btn-success m-b-10 m-l-5">添加二级栏目</button>
                                    </div>
                                </div>
                            </div>
                        </div><!-- /# column -->
                    </div><!-- /# row -->
                    </form>

            </div><!-- /# container-fluid -->
        </div><!-- /# main -->
    </div><!-- /# content wrap -->
</div>

<script src="__ADMIN_JS__/lib/jquery.min.js"></script><!-- jquery vendor -->
<script src="__ADMIN_JS__/lib/jquery.nanoscroller.min.js"></script><!-- nano scroller -->
<script src="__ADMIN_JS__/lib/sidebar.js"></script><!-- sidebar -->
<script src="__ADMIN_JS__/lib/bootstrap.min.js"></script><!-- bootstrap -->
<script src="__ADMIN_JS__/lib/mmc-common.js"></script>
<script src="__ADMIN_JS__/lib/mmc-chat.js"></script>
<script src="__ADMIN_LAYER__/layer.js"></script><!-- scripit init-->
</body>
<script>
    function subtop(){
        var topName = $('#topName').val();
        var icon = $('#icon').val();
        var clas = $('#clas').val();
        if(topName =='' || icon == ''|| clas == ''){
            layer.msg("参数不完整");
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '/admin/MenuAdd',
            data:{
                type:0,
                name:topName,
                icon:icon,
                clas:clas
            },
            dataType: 'json',
            success: function(data){
                layer.msg(data.msg);
                setTimeout(function(){
					window.location.reload();
                },1500);
            },
        });
    }

    function subsecond(){
        var secondName = $('#secondName').val();
        var sclas = $('#sclas').val();
        var pid = $('#pid').val();
        if(pid =='' || sclas =='' || secondName == ''){
            layer.msg("参数不完整");
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '/admin/MenuAdd',
            data:{
                type:1,
                name:secondName,
                clas:sclas,
                pid:pid
            },
            dataType: 'json',
            success: function(data){
                layer.msg(data.msg);
                setTimeout(function(){
                	window.location.reload();
                },1500);
            },
        });
    }
</script>
</html>